package com.demo.apparel.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 映射 /static/avatar/** 到项目根目录下的 avatar 文件夹
        //用户头像的图片
        String basePath = System.getProperty("user.dir") + "/avatar/";
        registry.addResourceHandler("/static/avatar/**")
                .addResourceLocations("file:" + basePath);

        //这是上传衣服的图片静态
        String uploadPath = System.getProperty("user.dir") + "/uploads/";
        registry.addResourceHandler("/static/image/**")
                .addResourceLocations("file:" + uploadPath);


        //这是提交反馈的图片静态地址
        String feedbackPath = System.getProperty("user.dir") + "/feedback/";
        registry.addResourceHandler("/static/feedback/**")
                .addResourceLocations("file:" + feedbackPath);

        // 管理员头像的图片
        String adminAvatarPath = System.getProperty("user.dir") + "/admin/avatar/";
        registry.addResourceHandler("/static/admin/avatar/**")
                .addResourceLocations("file:" + adminAvatarPath);

        //搭配图片的存储位置
        String MatchImagePath = System.getProperty("user.dir") + "/match/image/";
        registry.addResourceHandler("/static/match/image/**")
                .addResourceLocations("file:" + MatchImagePath);

        //商品图片的存储位置
        String GoodsImagePath = System.getProperty("user.dir") + "/goods/image/";
        registry.addResourceHandler("/static/goods/image/**")
                .addResourceLocations("file:" + GoodsImagePath);
    }
}
